<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../lib/layui-v2.6.3/css/layui.css" media="all">
  <link rel="stylesheet" href="../css/public.css" media="all">
</head>
<body>
<table>
  <tbody>
  <tr>
    <th></th>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td><button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn">挂号</button></td>
  </tr>
  <tr>
    <th></th>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td><button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn">挂号</button></td>
  </tr>
  <tr>
    <th></th>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td><button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn">挂号</button></td>
  </tr>
  <tr>
    <th></th>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td><button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn">挂号</button></td>
  </tr>
  <tr>
    <th></th>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td><button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn">挂号</button></td>
  </tr>
  <tr>
    <th></th>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td><button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn">挂号</button></td>
  </tr>
  <tr>
    <th></th>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td><button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn">挂号</button></td>
  </tr>
  </tbody>
<!--  <button id="eidt" style="width: 100px;height: 100px" >修改</button>-->
</table>
<script src="../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="https://code.jquery.com/jquery-3.0.0.min.js"></script>
<script>
  var shuju
  week = {
    Monday:[],
    Tuesday:[],
    Wednesday:[],
    Thursday:[],
    Friday:[],
    Saturday:[],
    Sunday:[],
  }
  const http = localStorage.getItem('http')
  $.ajax({
    method:'GET',
    url:http+`/Managers/findlist`,
    async:false,
    success:function (data,status){
      shuju = data.data
      const one = /^星期一/
      const two = /^星期二/
      const three = /^星期三/
      const four = /^星期四/
      const five = /^星期五/
      const six = /^星期六/
      const seven = /^星期日/
      for (let i = 0;i<shuju.length;i++)
      {
        const Monday = one.test(shuju[i])
        const Tuesday = two.test(shuju[i])
        const Wednesday = three.test(shuju[i])
        const Thursday = four.test(shuju[i])
        const Friday = five.test(shuju[i])
        const Saturday = six.test(shuju[i])
        const Sunday =seven.test(shuju[i])
        if(Monday){
          week.Monday.push(shuju[i].slice(3))
        }else if(Tuesday){
          week.Tuesday.push(shuju[i].slice(3))
        }else if (Wednesday){
          week.Wednesday.push(shuju[i].slice(3))
        }else if (Thursday){
          week.Thursday.push(shuju[i].slice(3))
        }else if (Friday){
          week.Friday.push(shuju[i].slice(3))
        }else if (Saturday){
          week.Saturday.push(shuju[i].slice(3))
        }else if (Sunday){
          week.Sunday.push(shuju[i].slice(3))
        }
      }
    }
  })
  window.onload=function (){
    var key =[]
    for (index in week)
    {
      key.push(index)
    }
    var table = $("table")
    let i =0;
    table.find("tr").each(function (){
      $(this).find("th").each(function (){
        $(this).text(key[i])
      })
      let j =0;
      $(this).find("td").each(function() {
        const num = key[i]
        $(this).text(week[`${num}`][j])
        j++
      });
      i++
    })
  }
  $(".layui-btn").on('click',function (){
    const da = localStorage.getItem("doctor")
    if (da == null)
    // {
    //   console.log("zheliwei kong ")
    //   localStorage.setItem("doctor",'false')
    // }
    console.log(da)
      if (da == null || da == 'false') {
      localStorage.setItem("doctor",'true')
      layer.open({
        type: 1, // page 层类型
        area: ['500px', '300px'],
        title: '挂号信息',
        shade: 0.6, // 遮罩透明度
        shadeClose: true, // 点击遮罩区域，关闭弹层
        closeBtn:0,
        anim: 0, // 0-6 的动画形式，-1 不开启
        content: '<div style="padding: 32px;">挂号成功</div>'
      });
      setTimeout(function (){
        layer.closeAll()
      },1000)
    }else {
      layer.open({
        type: 1, // page 层类型
        area: ['500px', '300px'],
        title: '挂号信息',
        shade: 0.6, // 遮罩透明度
        shadeClose: true, // 点击遮罩区域，关闭弹层
        closeBtn:0,
        anim: 0, // 0-6 的动画形式，-1 不开启
        content: '<div style="padding: 32px;">您已经挂号，请勿重复挂号</div>'
      });
      setTimeout(function (){
        layer.closeAll()
      },1000)
    }
            })
</script>
<style>
  table {
    width: 100vw;
    height: 100vh;
    border-collapse: collapse;
    border: 2px solid rgb(140 140 140);
    font-family: sans-serif;
    font-size: 0.8rem;
    letter-spacing: 1px;
  }

  caption {
    caption-side: bottom;
    padding: 10px;
    font-weight: bold;
  }

  thead,
  tfoot {
    background-color: rgb(228 240 245);
  }

  th,
  td {
    border: 1px solid rgb(160 160 160);
    padding: 8px 10px;
  }

  td:last-of-type {
    text-align: center;
  }

</style>
</body>
</html>

